/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kylingroup.J2SE.Desktop;

import java.awt.Desktop;  
    import java.io.File;  
    import java.net.URI;  
      
      
      
    public class DeskTopTest {  
          
        private static Desktop desktop;  
      
        //使用默认的浏览器打开网页  
        public static void browse(){  
            if (Desktop.isDesktopSupported()) {  
                desktop = Desktop.getDesktop();  
                try {  
                    //URI指定网页的地址  
                    desktop.browse(new URI("http://blog.csdn.net/dlutbrucezhang?viewmode=contents"));  
                } catch (Exception e) {  
                    // TODO: handle exception  
                    e.printStackTrace();  
                }  
            }  
        }  
          
        //编辑文件  
        public static void edit(){  
            if (Desktop.isDesktopSupported()) {  
                desktop = Desktop.getDesktop();  
                try {  
                    desktop.open(new File("/home/kylin/Documents/Screenshot from 2017-05-03 12-11-31.png"));  
                } catch (Exception e) {  
                    // TODO: handle exception  
                    e.printStackTrace();  
                }  
            }  
        }  
          
        //打开文件，它和编辑文件的过程类似，都是能看到文件的显示  
        public static void open() {  
            if (Desktop.isDesktopSupported()) {  
                desktop = Desktop.getDesktop();  
                try {  
                    desktop.open(new File("/home/kylin/Documents/公租房申请书.docx"));  
                } catch (Exception e) {  
                    // TODO: handle exception  
                    e.printStackTrace();  
                }  
            }  
        }  
          
        //打印指定的文件  
        public static void print() {  
            if (Desktop.isDesktopSupported()) {  
                desktop = Desktop.getDesktop();  
                try {  
                    desktop.open(new File("/home/kylin/Videos/lession00_环境搭建.avi"));  
                } catch (Exception e) {  
                    // TODO: handle exception  
                    e.printStackTrace();  
                }  
            }  
        }  
          
        /** 
         * @param args 
         */  
        public static void main(String[] args) {  
            // TODO Auto-generated method stub  
      
            browse();  
            edit();  
            open();  
            print();  
        }  
      
    }
